﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System;
using System.Windows.Controls;
using Xceed.Silverlight.Data;

namespace Xceed.Silverlight.DataGrid
{
  public sealed class CellValidationError : ValidationErrorBase
  {
    #region Constructors

    internal CellValidationError( DataPath dataPath, object dataItem, Column column, ValidationError validationError )
      : this( dataPath, dataItem, column, ( validationError.Exception != null ), validationError.ErrorContent, validationError.Exception )
    {
      m_validationError = validationError;
    }

    internal CellValidationError( DataPath dataPath, object dataItem, Column column, bool isRestrictive, object errorContent )
      : this( dataPath, dataItem, column, isRestrictive, errorContent, null )
    {
    }

    internal CellValidationError( DataPath dataPath, object dataItem, Column column, bool isRestrictive, object errorContent, Exception exception )
      : base( isRestrictive, errorContent, exception )
    {
      if( dataPath == null )
        throw new ArgumentNullException( "dataPath" );

      if( dataItem == null )
        throw new ArgumentNullException( "dataItem" );

      if( column == null )
        throw new ArgumentNullException( "column" );

      m_dataPath = dataPath;
      m_dataItem = dataItem;
      m_column = column;
    }

    #endregion

    #region Item Property

    public object Item
    {
      get
      {
        return m_dataItem;
      }
    }

    private readonly object m_dataItem;

    #endregion

    #region Column Property

    public Column Column
    {
      get
      {
        return m_column;
      }
    }

    private readonly Column m_column;

    #endregion

    #region DataPath Internal Property

    internal DataPath DataPath
    {
      get
      {
        return m_dataPath;
      }
    }

    private readonly DataPath m_dataPath;

    #endregion

    #region InternalValidationError Internal Property

    internal ValidationError InternalValidationError
    {
      get
      {
        return m_validationError;
      }
    }

    private readonly ValidationError m_validationError;

    #endregion
  }
}
